﻿// copyright (c) 2025 author:fio66<fio66@foxmail.com>. All rights reserved.
// date: 2025-08-22 17:38:27

#include "src/manager/audio_player_manager.h"

namespace fio66 {
void AudioPlayerManager::CallEvent(EventType event_type, const std::any& data) {
  for (auto* handler : event_handlers_[event_type]) {
    handler->OnEvent(event_type, data);
  }
}

void AudioPlayerManager::RegisterEvent(EventType event_type,
                                       EventHandler* handler) {
  event_handlers_[event_type].push_back(handler);
}
void AudioPlayerManager::UnregisterEvent(EventType event_type,
                                         EventHandler* handler) {
  auto& handlers = event_handlers_[event_type];
  handlers.erase(std::remove(handlers.begin(), handlers.end(), handler),
                 handlers.end());
}
}  // namespace fio66
